/*
 * sun_Net_ActorParam.js
 * 仿世界ol-角色属性
 * 
 */

//仿世界ol能力值
Game_BattlerBase.prototype.wparam = function (wparamId) {
    return 0;
}

const Net_BattlerBase_initMembers = Game_BattlerBase.prototype.initMembers;
Game_BattlerBase.prototype.initMembers = function () {
    Net_BattlerBase_initMembers.call(this);
    this.iniWparam();
}

/*
仿世界属性：
0-攻击次数
1-魔法命中
2-暴击伤害
3-状态抵抗
4-伤害减免
5-破甲
6-魔法穿透
7-洞察
8-治疗加成
*/
Game_BattlerBase.prototype.iniWparam = function () {
    this._wparam = [0, 0, 0, 0, 0, 0, 0, 0, 0]
}

Object.defineProperties(Game_BattlerBase.prototype, {
    atn: {
        get: function () {
            return this._wparam[0];
        },
        configurable: true
    },
    mht: {
        get: function () {
            return this._wparam[1];
        },
        configurable: true
    },
    crd: {
        get: function () {
            return this._wparam[2];
        },
        configurable: true
    },
    sre: {
        get: function () {
            return this._wparam[3];
        },
        configurable: true
    },
    drn: {
        get: function () {
            return this._wparam[4];
        },
        configurable: true
    },
    bka: {
        get: function () {
            return this._wparam[5];
        },
        configurable: true
    },
    mpn: {
        get: function () {
            return this._wparam[6];
        },
        configurable: true
    },
    ist: {
        get: function () {
            return this._wparam[7];
        },
        configurable: true
    },
    trb: {
        get: function () {
            return this._wparam[8];
        },
        configurable: true
    }
})

//加点系统
const Net_actor_setup = Game_Actor.prototype.setup;
Game_Actor.prototype.setup = function (actorId) {
    this._pointsBase = [0, 0, 0, 0, 0];
    this._pointsPlus = [0, 0, 0, 0, 0];
    this._points = 0;
    this.refreshPoints();
    Net_actor_setup.call(this, actorId);
}

const Net_levelUp = Game_Actor.prototype.levelUp;
Game_Actor.prototype.levelUp = function () {
    Net_levelUp.call(this);
    this.recoverAll();
    this.refreshPoints();
}

Game_Actor.prototype.refreshPoints = function () {
    //初始点数
    const inip = 10;
    //升级获得点数
    const ipp = 3;
    let sump = 0;
    for (const p of this._pointsBase) {
        sump += p;
    }
    this._points = inip + (this.level - 1) * 3 - sump;
}

Game_Actor.prototype.paramBase = function (paramId) {
    switch (paramId) {
        case 0:
            return 100 + this.level * 20 + this.points(0) * 2 + this.points(1) * 6;
        case 1:
            return 50 + this.level * 5 + this.points(3) * 5 + this.points(4) * 2;
        case 2:
            return 5 + this.points(0) * 3 + this.points(2);
        case 3:
            return 5 + this.points(0) * 5;
        case 4:
            return 5 + this.points(3) * 3 + this.points(4) * 1;
        case 5:
            return 5 + this.points(3) * 2 + this.points(4) * 4;
        case 6:
            return 0 + this.points(2) * 5 + this.points(4);
        case 7:
            return 0;
    }
}

Game_Actor.prototype.points = function (pointsId) {
    return this._pointsBase[pointsId] * this.pointsRate(pointsId) + this.pointsFlat(pointsId);
}

Game_Actor.prototype.pointsRate = function (pointsId) {
    return 1;
}

Game_Actor.prototype.pointsFlat = function (pointsId) {
    return 0;
}